package zy.zy5;

import java.io.*;

public class Test {
    public static void main(String[] args) {
        File file=new File("E:\\a\\1.txt");
        jiami(file);

    }

    public static void jiami(File file){
        File file1=new File("E:\\123.txt");
        String str=null;
        FileInputStream bin=null;
        FileOutputStream bout=null;
        try {
            bin=new FileInputStream(file);
            byte b[]=new byte[bin.available()];
            byte b1[]=new byte[bin.available()];
            bin.read(b);
            for (int i=0;i<b.length;i++){
                b1[i]= (byte) ~b[i];
            }


            bout=new FileOutputStream(file1);
            bout.write(b1);

            str=file.getAbsolutePath();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                bin.close();
                bout.close();
                System.out.println(file.delete());
                System.out.println(file1.renameTo(new File(str)));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
